package com.lagou.edu;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class StreamUtils {

    public static String getAbsolutePath(String path){
        return StreamUtils.class.getResource("/").getPath().replaceAll("\\\\","/") + "static/" + path + ".html";
    }

    public static void outPutStaticResource(InputStream inputStream, OutputStream outputStream) throws IOException {
        int available = inputStream.available();
        byte[] bytes = new byte[available];
        inputStream.read(bytes);
        String s = new String(bytes);
        outputStream.write(HttpProtocolUtil.getSucceeText(s).getBytes(StandardCharsets.UTF_8));
        outputStream.flush();
    }

}
